<?php
class ControllerModuleNewsletter extends Controller {
	protected function index($setting) {
		
		if (isset($setting['showTitle'])){
			$this->data['showTitle'] = $setting['showTitle'];
		}else{
			$this->data['showTitle'] = 0;//show
		}
		if (isset($setting['showType'])){
			$this->data['showType'] = $setting['showType'];
		}else{
			$this->data['showType'] = 0;//single
		}
				
		$this->data['action'] = $this->url->link('account/newsletter/addCustomer');
		if (!isset($this->request->get['route'])) {
			$this->data['redirect'] = $this->url->link();
		} else {
			$data = $this->request->get;
			unset($data['_route_']);
			$route = $data['route'];
			unset($data['route']);
			$url = '';
			if ($data) {
				$url = '&' . urldecode(http_build_query($data, '', '&'));
			}	
			if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
				$connection = 'SSL';
			} else {
				$connection = 'NONSSL';
			}			
			$this->data['redirect'] = $this->url->link($route, $url, $connection);
		}
		
		$this->language->load('module/newsletter');
      	$this->data['heading_title'] = $this->language->get('heading_title');
      	$this->data['entry_name'] = $this->language->get('entry_name');
      	$this->data['entry_email'] = $this->language->get('entry_email');
      	
      	$this->data['button_submit'] = $this->language->get('button_submit');
		
      	if (isset($this->request->post['name'])) {
      		$this->data['name'] = $this->request->post['name'];
      	}else{
      		$this->data['name'] = '';
      	}
      	if (isset($this->request->post['email'])) {
      		$this->data['email'] = $this->request->post['email'];
      		
      	}else{
      		$this->data['email'] = '';
      	}
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/newsletter.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/newsletter.tpl';
		} else {
			$this->template = 'default/template/module/newsletter.tpl';
		}

		$this->render();
	}
}
?>